<template>
	<view>
		<view class="bus_info tp-w690">
			<view class="info_top-wrap">
				<view class="date">
					<text class="type">租车</text>
					租车时间：{{dateInfo.time}}
				</view>
				<view class="status">
					<view>{{dateInfo.zucheStatus}}</view>
				</view>
			</view>

			<view class="info_content-wrap" @click="handleGoRentOrderDetail(dateInfo)">
				<view class="address-wrap">
					<view class="from">
						<text class="type">取</text>
						<text class="txt ellispsis1">{{dateInfo.startStation}}</text>
					</view>
					<view class="to">
						<text class="type">还</text>
						<text class="txt ellispsis1">{{dateInfo.endStation}}</text>
					</view>
				</view>
				<view class="price"><text style="font-size: 24rpx;">￥</text> {{dateInfo.price}}</view>
			</view>

			<view class="order_info-wrap">
				<view class="order_num">订单号：{{dateInfo.orderNo}}</view>
				<view class="btns">
					<view v-if="[0,1,2,3,4].includes(dateInfo.status-0)" class="btn cancle" @click="handleCancleOrder">
						取消订单</view>
					<view v-if="[5,10].includes(dateInfo.status-0)" class="btn pay" @click="handleReturnCar">还车</view>
					<view v-if="[0,9].includes(dateInfo.status-0)" class="btn pay" @click="handlePay">支付</view>
					<view v-if="dateInfo.status==2" class="btn pay" @click="handleGoRentOrderDetail">重新提交</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			dateInfo: {
				type: Object,
				default () {
					return {}
				}
			},
			curNavbar: {
				type: [Object, Boolean],
				default () {
					return false
				}
			}
		},
		data() {
			return {
				cancleOrderShouldPayMoney: 0,
			};
		},
		mounted() {

		},
		methods: {
			handlePay() {
				const _this = this
				if (_this.dateInfo.status == 9) {
					_this.$store.commit('upOrderPayType', 'rentAdd')
					uni.$emit('showCommonPay', _this.dateInfo)
				} else {
					// #ifdef MP-WEIXIN
					uni.requestSubscribeMessage({
						tmplIds: ['p08IN_BfeNZu8QEIasbY-BrW-sgyEX1z-4mW3BPE7P0'],
						success(res) {
							_this.submitWxNotifyConfirm('p08IN_BfeNZu8QEIasbY-BrW-sgyEX1z-4mW3BPE7P0', res[
								'p08IN_BfeNZu8QEIasbY-BrW-sgyEX1z-4mW3BPE7P0'])
							// #endif
							uni.$emit('showCommonPay', _this.dateInfo)
							// #ifdef MP-WEIXIN
						}
					})
					// #endif
				}
			},
			handleCancleOrder() {
				uni.$emit('cancleOrder', this.dateInfo)
			},
			handleGoRentOrderDetail() {
				uni.navigateTo({
					url: '../../pagesUser/order/rent.orderDetail?orderStatus=' + this.curNavbar.alias + '&id=' +
						this.dateInfo.orderNo
				});
			},
			handleSubmitBackReason(reason) { // 提交取消订单的原因
				this.cancleOrder(reason)
			},
			handleReturnCar() { // 还车
				this.$http.get(this.$api.returnRentCar, {
					orderNo: this.dateInfo.orderNo
				}).then(res => {
					if (res.code === 200) {
						uni.showToast({
							title: '还车成功'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bus_info {
		background: #fff;
		border-radius: 12rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-bottom: 20rpx;

		.info_top-wrap {
			height: 80rpx;
			display: flex;
			align-items: center;
			font-size: 26rpx;
			justify-content: space-between;
			padding: 0 20rpx;

			.date {
				color: #666;
				display: flex;
				align-items: center;

				.type {
					display: inline-block;
					width: 66rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					background-color: #FFF2E0;
					color: $yellow;
					font-size: 22rpx;
					margin-right: 20rpx;
					border-radius: 8rpx;
				}
			}

			.status {
				color: $yellow;
			}
		}

		.info_content-wrap {
			display: flex;
			flex: 1;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx;
			border-top: 1px solid #ebebeb;
			border-bottom: 1px solid #ebebeb;

			.address-wrap {
				display: flex;
				flex: 1;
				flex-direction: column;
				justify-content: space-between;
				font-size: 30rpx;
				font-weight: bold;
				position: relative;

				.from,
				.to {
					display: flex;
					align-items: center;

					.type {
						padding: 0 10rpx;
						background-color: #FFF2E0;
						color: $yellow;
						font-size: 22rpx;
						border-radius: 8rpx;
						margin-right: 20rpx;
						height: 40rpx;
						line-height: 40rpx;
						text-align: center;
					}
				}

				.from {
					margin-bottom: 20rpx;
				}
			}

			.price {
				color: $red;
				font-size: 36rpx;
				font-weight: bold;
			}
		}

		.order_info-wrap {
			height: 95rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #666;
			padding: 0 20rpx;

			.order_num {
				font-size: 26rpx;
			}

			.btns {
				display: flex;
				align-items: center;
				justify-content: flex-end;

				.btn {
					border-radius: 12rpx;
					padding: 0 15rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					min-width: 78rpx;
					font-size: 28rpx;

					&.cancle {
						background-color: #EBEBEB;
					}

					&.pay {
						color: #fff;
						background-color: $blue;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
</style>
